<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Home\Controller;

use Think\Controller;

/**
 * 林州市悟能科技提供技术支持
 * 400-037203
 * @author Mr_Lee :672288511;
 */
class LineController extends Controller
{
    public function _initialize()
    {
        if (empty($_SESSION['username'])) {

            //$this->error('页面加载中。。。',U('Login/Login'),1);
            $this->redirect('Login/Login');

        }
        $table1="line";
        $this->assign('table',$table1);
    }

    public function Lineadmin()
    {
        $Line = M('price')->select();
        $this->assign('line', $Line);
        $this->display();
    }

    public function addLine()
    {
        if (IS_AJAX) {
            $add = M('price');
            $add->create();
            $a = $add->add();
            if ($a) {
                $data = 0;

            } else {

                $data = 1;
            }
            echo $data;
        } else {

            $this->display();
        }

    }


    public function linexg()
    {
        if (IS_AJAX) {

            $price = M('price');
            $price->create();
            $a = $price->save();
            if ($a) {
                $data = 0;

            } else {

                $data = 1;
            }
            echo $data;
        } else {
            $map['id'] = I('get.id');
            $line = M('price')->where($map)->find();
            $this->assign('line', $line);
            $this->display();
        }

    }

    public function del()
    {
        $id = I('get.id');
        if (!empty($id)) {

            $map['id'] = $id;
            $del = M('price')->where($map)->delete();
            if ($del) {
                $this->success('删除成功');

            } else {

                $this->error('删除失败');
            }

        }
    }

    public function Lineadmin2()
    {
        $Line = M('dyprice')->select();
        $this->assign('line', $Line);
        $this->display();
    }

    public function addLine2()
    {
        if (IS_AJAX) {
            $add = M('dyprice');
            $add->create();
            $a = $add->add();
            if ($a) {
                $data = 0;

            } else {

                $data = 1;
            }
            echo $data;
        } else {

            $this->display();
        }

    }

    public function linexg2()
    {
        if (IS_AJAX) {

            $price = M('dyprice');
            $price->create();
            $a = $price->save();
            if ($a) {
                $data = 0;

            } else {

                $data = 1;
            }
            echo $data;
        } else {
            $map['id'] = I('get.id');
            $line = M('dyprice')->where($map)->find();
            $this->assign('line', $line);
            $this->display();
        }

    }

    public function del2()
    {
        $id = I('get.id');
        if (!empty($id)) {

            $map['id'] = $id;
            $del = M('dyprice')->where($map)->delete();
            if ($del) {
                $this->success('删除成功');

            } else {

                $this->error('删除失败');
            }

        }
    }
    //put your code here
}
